-- toolchains/my_fedora_gcc14.lua
toolchain("my_fedora_gcc14")
    set_kind("standalone")
    set_description("GCC 14.2.0 + CUDA 12.9")

    -------------------------------------------------
    -- 1) 指定编译器 / 汇编器 / 归档器
    -------------------------------------------------
    local gcc_root = "/usr"
    set_toolset("cc",   gcc_root .. "/bin/gcc")
    set_toolset("cxx",  gcc_root .. "/bin/g++")
    set_toolset("ld",   gcc_root .. "/bin/g++")
    set_toolset("ar",   gcc_root .. "/bin/gcc-ar")
    set_toolset("ranlib", gcc_root .. "/bin/gcc-ranlib")
    -- assembler; 编译 gcc14 需要先编译 binutils, 才带有 as
    -- set_toolset("as",   gcc_root .. "/bin/as")      

    set_toolset("cu",   "/usr/local/cuda-12.9/bin/nvcc") -- CUDA compiler


    -------------------------------------------------
    -- 2) 头文件 / 库搜索路径
    -------------------------------------------------
    add_includedirs(gcc_root .. "/include")
    add_linkdirs(gcc_root .. "/lib64")
    add_linkdirs("/usr/local/cuda-12.9/lib64")

    -------------------------------------------------
    -- 3) CUDA 专用设置（仅 nvcc 可见）
    -------------------------------------------------
    on_load(function (toolchain)
        -- 只对 nvcc 生效
        toolchain:add("cuflags", "-ccbin=" .. gcc_root .. "/bin/gcc")
        toolchain:add("sysincludedirs", "/usr/local/cuda-12.9/include")
    end)
toolchain_end()